package org.ehe.business.drawing.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.RequiredArgsConstructor;
import org.ehe.business.drawing.domain.bo.DesignDrawingSiteBo;
import org.ehe.business.drawing.domain.vo.DesignDrawingSiteVo;
import org.ehe.business.drawing.service.DesignDrawingSiteService;
import org.ehe.common.core.BaseController;
import org.ehe.common.core.domain.R;
import org.ehe.common.log.annotation.Log;
import org.ehe.common.log.enums.BusinessType;
import org.ehe.common.mybatis.core.page.PageQuery;
import org.ehe.common.mybatis.core.page.TableDataInfo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目图纸点位
 * @author :zhangnn
 * @className :DesignDrawingSiteController
 * @description: TODO
 * @date 2025-09-25 10:08:36
 */
@RestController
@RequestMapping("/drawing/site")
@RequiredArgsConstructor
public class DesignDrawingSiteController extends BaseController {
    private final DesignDrawingSiteService siteService;


    /**
     * 项目分页
     */
    @GetMapping("/page")
    public TableDataInfo<DesignDrawingSiteVo> page(DesignDrawingSiteBo bo, PageQuery pageQuery) {
        return siteService.pageQueryList(bo,pageQuery);
    }



    /**
     * 树形列表
     */
    @GetMapping("/tree")
    public R<List<DesignDrawingSiteVo>> tree(DesignDrawingSiteBo bo) {
        return R.ok(siteService.treeList(bo));
    }

    /**
     * 新增
     */
    @SaCheckPermission("drawing:site:add")
    @Log(title = "新增点位", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Long> add(@Validated @RequestBody DesignDrawingSiteBo bo) {
        return R.ok(siteService.addSite(bo));
    }

    /**
     * 编辑
     *
     */
    @SaCheckPermission("drawing:site:edit")
    @Log(title = "编辑点位", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Boolean> edit(@Validated @RequestBody DesignDrawingSiteBo bo) {
        return R.ok(siteService.editSite(bo));
    }

    /**
     * 删除
     */
    @SaCheckPermission("drawing:site:remove")
    @Log(title = "删除点位", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public R<Boolean> del(@PathVariable Long id) {
        return R.ok(siteService.deleteSite(id));
    }
}
